package org.zzz.controller;

import org.zzz.entity.TeacherCourse;
import org.zzz.service.TeacherCourseService;
import org.zzz.service.impl.TeacherCourseServiceImpl;
import org.zzz.utils.Result;

/**
 * @Author ZZF
 * @Time 2021/04/20 22:59
 */
public class TeacherCourseController {
    private TeacherCourseService teacherCourseService = new TeacherCourseServiceImpl();

    public Result<TeacherCourse> getTCByTid(String tid){
        TeacherCourse tc = teacherCourseService.getTCByTid(tid);
        return tc != null ? Result.success("查询成功").data(tc) : Result.error("查无数据");
    }

    /**
     * 根据教师id获取任课课程(可能不需要单独用到)
     * @param tid
     * @return
     */
    public Result<String> getCourseNamesByTid(String tid){
        return Result.success("查询成功").data(teacherCourseService.getCourseNamesByTid(tid));
    }

    /**
     *
     * 根据教师id获取任课课程名称
     * @param tid
     * @return
     */
    public Result<String> getCourseNameByTid(String tid){
        return Result.success("查询成功").data(teacherCourseService.getCourseNameByTid(tid));

    }

    /**
     * 根据课程id获取课程
     * @param cid
     * @return
     */
    public Result<TeacherCourse> getTCByCid(String cid){
        TeacherCourse tc = teacherCourseService.getTCByCid(cid);
        return tc != null ? Result.success("查询成功").data(tc) : Result.error("查无此数据");
    }

//    public Result<TeacherCourse> getTCByTid(String tid){
//        TeacherCourse tc = teacherCourseService.getTCByTid(tid);
//        return tc != null ? Result.success("查询成功").data(tc) : Result.error("查无此数据");
//    }


    /**
     * 添加教师课程
     * @param teacherCourse
     * @return
     */
    public Result insertTC(TeacherCourse teacherCourse) {
        return teacherCourseService.insertTC(teacherCourse) == true ? Result.success("添加成功") : Result.error("添加失败");
    }

    /**
     * 修改教师课程
     * @param teacherCourse
     * @return
     */
    public Result updateTC(TeacherCourse teacherCourse){
        return teacherCourseService.updateTC(teacherCourse) == true ? Result.success("修改成功") : Result.error("修改失败");
    }

    /**
     * 删除教师课程
     * @param id
     * @return
     */
    public Result deleteTCById(String id){
        return teacherCourseService.deleteTCById(id) == true ? Result.success("删除成功") : Result.error("删除失败");
    }
}
